package io.renren.modules.blog.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.blog.entity.LableEntity;
import io.renren.modules.blog.service.LableService;
import com.mili.common.utils.PageUtils;
import com.mili.common.utils.R;



/**
 * 
 *
 * @author lujianhong
 * @email milimall@qq.com
 * @date 2020-10-26 14:02:33
 */
@RestController
@RequestMapping("/blog/lable")
public class LableController {
    @Autowired
    private LableService lableService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("blog:lable:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = lableService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{lableId}")
    @RequiresPermissions("blog:lable:info")
    public R info(@PathVariable("lableId") Integer lableId){
		LableEntity lable = lableService.getById(lableId);

        return R.ok().put("lable", lable);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("blog:lable:save")
    public R save(@RequestBody LableEntity lable){
		lableService.save(lable);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("blog:lable:update")
    public R update(@RequestBody LableEntity lable){
		lableService.updateById(lable);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("blog:lable:delete")
    public R delete(@RequestBody Integer[] lableIds){
		lableService.removeByIds(Arrays.asList(lableIds));

        return R.ok();
    }

}
